package com.xbongbong.pro.message.pushset;/*/*/

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.message.domain.entity.PushSetEntity;
import com.xbongbong.pro.message.base.AbstractPushSet;
import com.xbongbong.pro.message.model.PushSetModel;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * 退款消息设置
 *
 * @author GuoJun.HU
 * @since V1.0
 * @date 2019/2/19 11:03
 */
@Getter
@Setter
public class RefundPushSet extends AbstractPushSet {

    private String pushObject;

    @Override
    public PushSetEntity toPushSetEntity(String pushObject, String pushTime, String attrEntity) {

        setPushObject(pushObject);

        PushSetEntity pushSetEntity = new PushSetEntity();

        pushSetEntity.setAddTime(addTime);
        pushSetEntity.setAttrEntity(attrEntity);
        pushSetEntity.setCorpid(corpid);
        pushSetEntity.setDel(del);
        pushSetEntity.setEnable(enable);
        pushSetEntity.setId(id);
        pushSetEntity.setPushObject(pushObject);
        pushSetEntity.setPushTime(pushTime);
        pushSetEntity.setRefEntity(refEntity);
        pushSetEntity.setSubType(subType);
        pushSetEntity.setType(type);
        pushSetEntity.setUpdateTime(updateTime);
        return pushSetEntity;
    }

    @Override
    public PushSetEntity getPushSet(String corpid, Integer subType, PushSetModel pushSetModel) {
        /*Integer type = PushTypeEnum.REFUND_PUSH.getCode();

        Map<String, Object> param = new HashMap<>(16);
        param.put("corpid", corpid);
        param.put("type", type);
        param.put("subType", subType);

        List<PushSetEntity> pushSetList = pushSetModel.findEntitys(param);
        PushSetEntity pushSetEntity;
        if (pushSetList.isEmpty()) {
            pushSetEntity = new PushSetEntity();
            pushSetEntity.setType(type);
            pushSetEntity.setSubType(subType);
            pushSetEntity.setEnable(1);
            JSONObject pushObject = new JSONObject();
            if (Objects.equals(PushTypeEnum.REFUND_ADD_PUSH.getSubCode(), subType)) {
                pushSetEntity.setTitle(PushTypeEnum.REFUND_ADD_PUSH.getName());
                pushSetEntity.setContent(PushSetConstant.REFUND_ADD);
                //type
                JSONArray typeArray = new JSONArray();
                JSONObject object = new JSONObject();
                object.put("name", PushObjectTypeEnum.MAINUSER.getName());
                object.put("alias", PushObjectTypeEnum.MAINUSER.getAlias());
                object.put("enable", 1);
                typeArray.add(object);
                JSONObject object1 = new JSONObject();
                object1.put("name", PushObjectTypeEnum.COLLABORATOR.getName());
                object1.put("alias", PushObjectTypeEnum.COLLABORATOR.getAlias());
                object1.put("enable", 0);
                typeArray.add(object1);
                pushObject.put("type", typeArray);
                //manager
                JSONObject managerObject = new JSONObject();
                managerObject.put("enable", 0);
                managerObject.put("value", new ArrayList<>());
                pushObject.put("manager", managerObject);
                //role
                JSONObject roleObject = new JSONObject();
                roleObject.put("enable", 0);
                roleObject.put("value", new ArrayList<>());
                pushObject.put("role", roleObject);

            } else if (Objects.equals(PushTypeEnum.REFUND_ADD_WITH_PRODUCT_PUSH, subType)) {
                pushSetEntity.setTitle(PushTypeEnum.REFUND_ADD_WITH_PRODUCT_PUSH.getName());
                pushSetEntity.setContent(PushSetConstant.REFUND_ADD_WITH_PRODUCT);
                //type
                JSONArray typeArray = new JSONArray();
                JSONObject object = new JSONObject();
                object.put("name", PushObjectTypeEnum.MAINUSER.getName());
                object.put("alias", PushObjectTypeEnum.MAINUSER.getAlias());
                object.put("enable", 1);
                typeArray.add(object);
                JSONObject object1 = new JSONObject();
                object1.put("name", PushObjectTypeEnum.COLLABORATOR.getName());
                object1.put("alias", PushObjectTypeEnum.COLLABORATOR.getAlias());
                object1.put("enable", 0);
                typeArray.add(object1);
                JSONObject object2 = new JSONObject();
                object2.put("name", PushObjectTypeEnum.CONTRACT_SIGNING.getName());
                object2.put("alias", PushObjectTypeEnum.CONTRACT_SIGNING.getAlias());
                object2.put("enable", 1);
                typeArray.add(object2);
                pushObject.put("type", typeArray);
                //manager
                JSONObject managerObject = new JSONObject();
                managerObject.put("enable", 0);
                managerObject.put("value", new ArrayList<>());
                pushObject.put("manager", managerObject);
                //role
                JSONObject roleObject = new JSONObject();
                roleObject.put("enable", 0);
                roleObject.put("value", new ArrayList<>());
                pushObject.put("role", roleObject);
                //user
                JSONObject userObject = new JSONObject();
                userObject.put("enable", 0);
                userObject.put("value", new ArrayList<>());
                pushObject.put("user", userObject);
            } else if (Objects.equals(PushTypeEnum.REFUND_ADD_WITHOUT_PRODUCT_PUSH.getSubCode(), subType)) {
                pushSetEntity.setTitle(PushTypeEnum.REFUND_ADD_WITHOUT_PRODUCT_PUSH.getName());
                pushSetEntity.setContent(PushSetConstant.REFUND_ADD_WITHOUT_PRODUCT);
                //type
                JSONArray typeArray = new JSONArray();
                JSONObject object = new JSONObject();
                object.put("name", PushObjectTypeEnum.MAINUSER.getName());
                object.put("alias", PushObjectTypeEnum.MAINUSER.getAlias());
                object.put("enable", 1);
                typeArray.add(object);
                JSONObject object1 = new JSONObject();
                object1.put("name", PushObjectTypeEnum.COLLABORATOR.getName());
                object1.put("alias", PushObjectTypeEnum.COLLABORATOR.getAlias());
                object1.put("enable", 0);
                typeArray.add(object1);
                JSONObject object2 = new JSONObject();
                object2.put("name", PushObjectTypeEnum.CONTRACT_SIGNING.getName());
                object2.put("alias", PushObjectTypeEnum.CONTRACT_SIGNING.getAlias());
                object2.put("enable", 1);
                typeArray.add(object2);
                pushObject.put("type", typeArray);
                //manager
                JSONObject managerObject = new JSONObject();
                managerObject.put("enable", 0);
                managerObject.put("value", new ArrayList<>());
                pushObject.put("manager", managerObject);
                //role
                JSONObject roleObject = new JSONObject();
                roleObject.put("enable", 0);
                roleObject.put("value", Collections.singletonList(22));
                pushObject.put("role", roleObject);
                //user
                JSONObject userObject = new JSONObject();
                userObject.put("enable", 0);
                userObject.put("value", new ArrayList<>());
                pushObject.put("user", userObject);
            }
            pushSetEntity.setPushObject(pushObject.toJSONString());
        } else {
            pushSetEntity = pushSetList.get(0);
            if (Objects.equals(PushTypeEnum.REFUND_ADD_PUSH.getSubCode(), subType)) {
                pushSetEntity.setTitle(PushTypeEnum.REFUND_ADD_PUSH.getName());
                pushSetEntity.setContent(PushSetConstant.REFUND_ADD);

            } else if (Objects.equals(PushTypeEnum.REFUND_ADD_WITH_PRODUCT_PUSH, subType)) {
                pushSetEntity.setTitle(PushTypeEnum.REFUND_ADD_WITH_PRODUCT_PUSH.getName());
                pushSetEntity.setContent(PushSetConstant.REFUND_ADD_WITH_PRODUCT);

            } else if (Objects.equals(PushTypeEnum.REFUND_ADD_WITHOUT_PRODUCT_PUSH.getSubCode(), subType)) {
                pushSetEntity.setTitle(PushTypeEnum.REFUND_ADD_WITHOUT_PRODUCT_PUSH.getName());
                pushSetEntity.setContent(PushSetConstant.REFUND_ADD_WITHOUT_PRODUCT);

            }
        }
        return pushSetEntity;*/
        return null;
    }

    @Override
    public PushSetEntity getPushSet(String corpid, String attr, PushSetModel pushSetModel) {
        return null;
    }

    @Override
    public List<PushSetEntity> getPushSet(String corpid, List<String> attrList, PushSetModel pushSetModel, Long templateId) {
        return null;
    }

    @Override
    public JSONObject getTimeJson(JSONObject jsonObject) {
        return null;
    }
}
